package cn.webrx.wxs.mapper;

import cn.webrx.wxs.entity.GoodsCategory;
import cn.webrx.wxs.vo.VoGoodsCate;
import cn.webrx.wxs.vo.VoGoodsCateAdd;
import org.apache.ibatis.annotations.*;

import java.util.List;
import java.util.Map;

public interface GoodsCategoryMapper {
    int deleteByPrimaryKey(Integer id);

    int insert(GoodsCategory record);

    GoodsCategory selectByPrimaryKey(Integer id);

    List<GoodsCategory> selectAll();

    int updateByPrimaryKey(GoodsCategory record);

    List<VoGoodsCate> queryGoodsCate();

    List<VoGoodsCateAdd> showAddCate();

    @Update("update ws_goods_category set is_show=#{state} where id = #{id}")
    int updateSwitchState(@Param("id") int id, @Param("state") int state);

    @Delete("delete from ws_goods_category where id = #{ids}")
    int del(int ids);

    @Select("select count(0) from ws_goods_category where pid = #{ids}")
    int isDel(int ids);

    @Select("select id,name,level,pid from ws_goods_category")
    List<Map<String,Object>> showCate();



    @Insert("insert into ws_goods_category(name,pid,level,sort,is_show,image,remark) value(#{name},#{pid},#{level},#{sort},#{is_show},#{image},#{remark})")
    int save(GoodsCategory cate);

    @Select("select level+1 from ws_goods_category where id = #{id} ")
    int getLevel(int id);

    @Select("select id,name,pid,level,sort,is_show,image,remark from ws_goods_category where id = #{id}")
    GoodsCategory queryById(int id);

    @Update("update ws_goods_category set name=#{name},pid=#{pid},level=#{level},sort=#{sort},is_show=#{is_show},image=#{image},remark=#{remark} where id = #{id}")
    int update(GoodsCategory cate);
}